package cn.edu.lnpu.manage.cms.controller;

import cn.edu.lnpu.api.cms.CmsTemplateControllerApi;
import cn.edu.lnpu.common.model.response.QueryResponseResult;
import cn.edu.lnpu.common.model.response.ResponseResult;
import cn.edu.lnpu.domain.cms.CmsTemplate;
import cn.edu.lnpu.domain.cms.CmsTemplateContent;
import cn.edu.lnpu.manage.cms.service.CmsTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cms/template")
public class CmsTemplateController implements CmsTemplateControllerApi {

    @Autowired
    private CmsTemplateService cmsTemplateService;

    @GetMapping("/list")
    public QueryResponseResult<CmsTemplate> list() {
        return cmsTemplateService.list();
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CmsTemplate cmsTemplate) {
        return cmsTemplateService.save(cmsTemplate);
    }

    @Override
    @PostMapping("/save/content")
    public ResponseResult saveTemplateContent(@RequestBody CmsTemplateContent content) {
        return cmsTemplateService.saveTemplateContent(content);
    }
}
